<?php
// $Id$

/**
 * Controller_Deposit 控制器
 */
class Controller_Deposit extends Controller_Abstract
{

	function actionIndex()
	{
        // 为 $this->_view 指定的值将会传递数据到视图中
		# $this->_view['text'] = 'Hello!';
	}
	
	function actionNew(){
		
		if($this->_context->isPOST()){
			$user = $this->_app->currentUser();
			
			try {
				$_POST['user_id'] = $user['id'];
				$deposit = new Deposit($_POST);
				$deposit->save();
				return json_encode(array('success'=>true));
			}
			catch (QDB_ActiveRecord_ValidateFailedException $e){
				return json_encode(array('errorMsg' => $e->getMessage()));
			}
			catch (QDB_Exception $e){
				return json_encode(array('errorMsg' => $e->getMessage()));
			}
		}
		
	}
}


